import java.util.List;

/**
 * 计算同一个人的总成绩的实现类
 */
public class TotalScoreCalculatorImpl implements TotalScoreCalculator {
    @Override
    public double calculateTotalScore(List<Grade> grades, String input) {
        double totalScore = 0;
        for (Grade grade : grades) {
            Student student = grade.getStudent();
            if (student.getStudentId().equals(input) || student.getName().equals(input)) {
                totalScore += grade.getScore();
            }
        }
        return totalScore;
    }
}    